package com.gwt.tirso.gymkhana.client;

import java.util.List;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class ContestStep2 implements EntryPoint{
	
	private Label validAccess = new Label("Acceso válido");
	private Label descLabel = new Label("Descripción");
	private Label rulesLabel = new Label("Reglas");
	private Button nextBt = new Button("Empezar");
	private Label desc = new Label();
	private Label rules = new Label();
	private VerticalPanel mainPanel = new VerticalPanel();
	
	private Gymkhana g;
	private List<Question> lq;

	

	@Override
	public void onModuleLoad() {
		
		loadContestStep2();
			
	}

	private void loadContestStep2() {
		validAccess.setStyleName("labelAdvice");
		mainPanel.add(validAccess);
		
		mainPanel.add(descLabel);
		
		//description and rules are in field Gymkhana
		desc.setText(g.getDescription());
		desc.setStyleName("labelText");
		mainPanel.add(desc);
		
		mainPanel.add(rulesLabel);
		
		rules.setText(g.getRules());
		rules.setStyleName("labelText");
		mainPanel.add(rules);
		
		nextBt.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				step3();				
			}
		});
		
		mainPanel.add(nextBt);
		mainPanel.addStyleName("contestNext");
		RootPanel.get("contest").add(mainPanel);	
		
	}

	protected void step3() {
		
		int nQuestion = 0;
		String code = "0000";
		ContestStep3 c3 = new ContestStep3(g, lq, nQuestion, code);
		c3.onModuleLoad();
		RootPanel.get("contest").remove(mainPanel);
		
	}
	public void setGymkhana(Gymkhana result) {
		g = result;	
	}
}
